package cn.codesugar.broadcast

import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.util.Log
import android.widget.Toast

class MyBroadcastReceiver : BroadcastReceiver() {

    override fun onReceive(context: Context, intent: Intent) {
        if (intent.action == "cn.codesugar.broadcast.MY_BROADCAST") {
            Toast.makeText(context, "received in MyBroadcastReceiver", Toast.LENGTH_SHORT).show()
            Log.e("20210611", "received in MyBroadcastReceiver")
            // 打断广播
            abortBroadcast()
        }
    }
}